define(['jquery', 'bootstrap', 'utilback', 'table', 'form'], function ($, undefined, Utilback, Table, Form) {

    var Controller = {
    	config: {
    		get_url: '/member/read/detail',
    	},
        init: function () {
            $('.btn-search').on('click', function() {
            	$('#search-form').submit();
            });
            $('#search-form').data("validator-options", {
                invalid: function (form, errors) {
                    $.each(errors, function (i, j) {
                        Toastr.error(j);
                    });
                },
                target: '#errtips'
            }).validator($.extend({
                validClass: 'has-success',
                invalidClass: 'has-error',
                bindClassTo: '.form-group',
                formClass: 'n-default n-bootstrap',
                msgClass: 'n-right',
                stopOnError: true,
                display: function (elem) {
                    return $(elem).closest('.form-group').find(".control-label").text().replace(/\*/, '').replace(/\:{0}：/, '').trim();
                },
                target: function (input) {
                    var $formitem = $(input).closest('.form-group'),
                        $msgbox = $formitem.find('span.msg-box');
                    if (!$msgbox.length) {
                        return [];
                    }
                    return $msgbox;
                },
                valid: function (ret) {
                    //验证通过提交表单
                    var params = $('#search-form').serialize();
                    $.ajax({
                        type: 'get',
                        url: '/member/read/one',
                        data: params,
                        success: function (d) {
                            if (d.code == '200') {
                               $('#result-form').autofill(d.data);
                               $("#searchResult").modal("show");
                            }
                        }
                    });
                    return false;
                }
            }, $('#search-form').data("validator-options") || {}));
        }
    };
    return Controller;
});